package Controller.servlet;

import DAO.DoForUser;
import Domain.UserBean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/sign")
public class SignServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String username = req.getParameter("username");
        String password = req.getParameter("password");

        UserBean userBean = DoForUser.checkUser(new UserBean(null,username, password,null,null,null,null));

        if(userBean!=null){
            req.setAttribute("user",userBean);
            req.getRequestDispatcher("/nav.html").forward(req,resp);
        }else {


            req.getRequestDispatcher("/sign.html").forward(req,resp);
        }

    }
}
